package com.factors.TangChuan.Extracurricular_Activities;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class ExtracurricularActivitiesCountMapper extends Mapper<LongWritable, Text, Text, IntWritable> {

    private final static IntWritable one = new IntWritable(1);
    private Text extracurricularActivityStatus = new Text();

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {


        String[] columns = value.toString().split(",");
        if (columns.length >= 20) {
            try {
                String extracurricularActivities = columns[4];


                extracurricularActivityStatus.set(extracurricularActivities);
                context.write(extracurricularActivityStatus, one);
            } catch (Exception e) {

            }
        }
    }
}